#include "singleton.h"

namespace Opl
{
	namespace Core
	{
		Singleton* Singleton::m_Instance = 0;
		Singleton::~Singleton(void)
		{
		}

		Singleton* Singleton::instance()
		{
			static QMutex mutex;

			if (!m_Instance) {
				mutex.lock();

				if (!m_Instance) {
					m_Instance = new Singleton;
				}

				mutex.unlock();
			}

			return m_Instance;
		}

		void Singleton::drop()
		{
			static QMutex mutex;
			mutex.lock();
			delete m_Instance;
			m_Instance = 0;
			mutex.unlock();
		}
	}
}